﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AddCustomer : System.Web.UI.Page
{
    private SOAWebService.Service1 ser = new SOAWebService.Service1();
    protected void Page_Load(object sender, EventArgs e)
    {
        txtID.Text = ShowId();
    }

    protected string ShowId()
    {
        string id=ser.GetMaxID();
        int length = id.Length;
        string lstr = id.Substring(0, 3);
        string rstr = id.Substring(3, length-3);
        int rnum = int.Parse(rstr) + 1;
        rstr =rnum .ToString ();
        int i = length - 3 - rstr.Length;
        while (i > 0)
        {
            lstr += 0;
            i--;
        }
        id = lstr + rstr;
        return id;
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (ser.CreateCustomer(txtID.Text, txtName.Text, txtTel.Text, txtEmail.Text, txtVehicle.Text))
        {
            Response.Write("<script>alert('数据添加成功')</script>");
            Response.Write("<script>window.close()</script>");
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        
    }
}
